﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.woodsoft.core;
using com.woodsoft.core.Files;
using EQ1.Elements;
using EQ1.Templates;
using EQ1.Objects;

namespace EQ1.Templates {
  public class ScrollbarDrawTemplate : UIClass , IUIElement<ScrollbarDrawTemplate> {
    public ScrollbarDrawTemplate ( UIDocument doc , string name )
      : base( doc , name ) {
    }
    public ScrollbarDrawTemplate ( UIDocument doc )
      : this( doc , "ScrollbarDrawTemplate" ) {
    }

    #region IUIElement<ScrollbarDrawTemplate> Members

    public void Validate ( ScrollbarDrawTemplate val , string name ) {
      UIClass par = ( UIClass ) this.ParentNode;

      if( val.LocalName != name ) {
        ScrollbarDrawTemplate el = new ScrollbarDrawTemplate( ( UIDocument ) val.OwnerDocument , name );
        el.Copy( val );
        val = el;
      }

      if( par.GetElement( name ) != null )
        par.RemoveElement( name );

      par.AppendChild( val );
    }
    public void Copy ( ScrollbarDrawTemplate val ) {
      base.Copy( val );

      if( val.UpButton != null )
        this.UpButton = val.UpButton;
      if( val.DownButton != null )
        this.DownButton = val.DownButton;
      if( val.Thumb != null )
        this.Thumb = val.Thumb;
      if( string.IsNullOrEmpty( val.MiddleTextureInfo ) )
        this.MiddleTextureInfo = val.MiddleTextureInfo;
      if( val.MiddleTint != null )
        this.MiddleTint = val.MiddleTint;
    }

    #endregion
    
    public ButtonDrawTemplate UpButton {
      get {
        return ( ButtonDrawTemplate ) this.GetElement( "UpButton" );
      }
      set {
        this.UpButton.Validate( value , "UpButton" );
      }
    }
    public ButtonDrawTemplate DownButton {
      get {
        return ( ButtonDrawTemplate ) this.GetElement( "DownButton" );
      }
      set {
        this.DownButton.Validate( value , "DownButton" );
      }
    }
    public FrameTemplate Thumb {
      get {
        return ( FrameTemplate ) this.GetElement( "Thumb" );
      }
      set {
        this.Thumb.Validate( value , "Thumb" );
      }
    }
    public string MiddleTextureInfo {
      get {
        return this.GetElement( "MiddleTextureInfo" ).InnerText;
      }
      set {
        this.Validate( "MiddleTextureInfo" , value );
      }
    }
    public RGB MiddleTint {
      get {
        return ( RGB ) this.GetElement( "MiddleTint" );
      }
      set {
        this.MiddleTint.Validate( value , "MiddleTint" );
      }
    }

  }
}
